
const fs = require('fs')
const { resolve } = require('path')

new Promise((resolve, reject) => {
    fs.readFile('./resource/1.txt', (err, data) => {
        if (err) reject(err)
        resolve(data)
    })
}).then(value => {
    return new Promise((resolve, reject) => {
        fs.readFile('./resource/2.txt', (err, data) => {
            if (err) reject(err)
            resolve([value, data])
        })
    })

}).then(value => {
    return new Promise((resolve, reject) => {
        fs.readFile('./resource/3.txt', (err, data) => {
            if (err) reject(err)
            resolve([...value, data])//返回的是Buffer格式的数据
        })
    })
}).then(value => {
    console.log(value.toString())//1111,2222,3333
})